using System.ComponentModel.DataAnnotations;

namespace MonitorPlatform.Data.Entities
{
    public class MetricAggregate : BaseEntity
    {
        [Required]
        [StringLength(50)]
        public string AppId { get; set; } = string.Empty;

        [Required]
        [StringLength(50)]
        public string MetricType { get; set; } = string.Empty; // Performance, Error, API, Behavior

        [Required]
        [StringLength(20)]
        public string AggregateType { get; set; } = string.Empty; // Hour, Day, Week, Month

        public DateTime TimeBucket { get; set; }

        // Aggregated Values
        public long Count { get; set; } = 0;
        public double? Sum { get; set; }
        public double? Average { get; set; }
        public double? Min { get; set; }
        public double? Max { get; set; }
        public double? Median { get; set; }
        public double? P95 { get; set; }
        public double? P99 { get; set; }

        // Standard Deviation
        public double? StandardDeviation { get; set; }

        // Specific Metric Aggregations
        public long? ErrorCount { get; set; }
        public long? SessionCount { get; set; }
        public long? UserCount { get; set; }
        public long? PageViewCount { get; set; }

        // Performance Specific
        public double? AvgResponseTime { get; set; }
        public double? AvgPageLoadTime { get; set; }
        public double? AvgFirstContentfulPaint { get; set; }
        public double? AvgLargestContentfulPaint { get; set; }

        // Error Rate
        public double? ErrorRate { get; set; }

        // Additional Aggregated Data (JSON)
        public string? AdditionalData { get; set; }

        // Data Quality
        public long? SampleSize { get; set; }
        public double? ConfidenceLevel { get; set; }

        // Metadata
        public DateTime LastUpdated { get; set; }
        public string? DataSource { get; set; }
    }
} 